#ifndef FACTORYCLASS_H
#define FACTORYCLASS_H
#include <iostream>
#include <memory>

class Animal{
public:
    virtual void eat() = 0;
    virtual ~Animal() = default;
};

class Cat : public Animal{
public:
    void eat() override{
        std::cout << "猫吃饭" << std::endl;
    }
};
class Dog : public Animal{
public:
    void eat() override{
        std::cout << "狗吃饭" << std::endl;
    }
};

class Factory{
public:
    enum Type{
        CAT,
        DOG
    };
    static std::shared_ptr<Animal> getAnimal(const Type t){
        switch (t) {
        case CAT:
            return std::make_shared<Cat>();
        case DOG:
            return std::make_shared<Dog>();
        default:
            return nullptr;
        }
    }
};

#endif // FACTORYCLASS_H
